<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="id" type="java.lang.String" required="true" description="编号"%>
<%@ attribute name="name" type="java.lang.String" required="true" description="输入框名称"%>
<%@ attribute name="value" type="java.lang.String" required="true" description="输入框值"%>
<i id="${id}Icon" class="icon-${not empty value?value:' hide'}"></i>&nbsp;<label id="${id}IconLabel">${not empty value?value:'无'}</label>&nbsp;
<input id="${id}" name="${name}" type="hidden" value="${value}"/><a id="${id}Button" href="javascript:" class="btn">选择</a>&nbsp;&nbsp;
<script type="text/javascript">
	$("#${id}Button").click(function(){

        top.layer.open({
            type: 2,
            title:"选择图标",
            area: ['700px',  $(top.document).height()-180+"px"],
            content: '${ctx}/tag/iconselect?value="+$("#${id}").val()',
            btn: ['确定', '关闭'],
            yes: function(index, layero){ //或者使用btn1
//                var icon = layero.find("iframe")[0].contentWindow.$("#icon").val();
//                $("#iconIcon").attr("class", "fa "+icon);
//                $("#iconIconLabel").text(icon);
//                $("#icon").val(icon);
//                top.layer.close(index);

                var icon = layero.find("iframe")[0].contentWindow.$("#icon").val();
//                icon = $.trim(icon).substr(5);
                icon = $.trim(icon);
                $("#${id}Icon").attr("class", "fa fa-"+icon);
                $("#${id}IconLabel").text(icon);
                $("#${id}").val(icon);

                top.layer.close(index);
            },cancel: function(index){ //或者使用btn2
                $("#${id}Icon").attr("class", "icon- hide");
                $("#${id}IconLabel").text("无");
                $("#${id}").val("");
            }
        });
	});
</script>
